#include<bits/stdc++.h>
using namespace std;
int d[100005],v[100005],a[100005];
int qs[100005],zh[100005];
map<int,int> mp;
map<int,int> mpdjg;
int djg[100005];
int csgl[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    int T;
    cin>>T;
    while(T--){
        int n,m;
        double L,V;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            qs[i]=-1;
            zh[i]=-1;
        }
        int csc=0,kgcs=0;
        bool f=0;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]<0){
                f=1;
            }
        }
        int cs;
        for(int i=1;i<=m;i++){
            cin>>cs;
            mp[cs]++;
            //tong yi wei zhi ke neng you duo ge
            mpdjg[cs]=i;
        }
        for(int i=1;i<=n;i++){
            for(int j=d[i];j<=L;j++){
                int vx=sqrt(pow(v[i],2)+2*a[i]*(j-d[i]));
                if(vx<V&&a[i]<=0){
                    continue;
                }
                if(vx>V){
                    if(mp[j]!=0){
                        csgl[i]=1;
                        if(qs[n]==-1){
                            qs[n]=mpdjg[j];
                        }
                        zh[n]=mpdjg[j];
                    }
                }
            }
        }
        for(int i=1;i<=n;i++){
            if(csgl[i]!=0){
                csc++;
            }
        }
        cout<<csc<<" ";
        if(f==0){
            if(csc==0){
                cout<<n<<endl;
            }
            else{
                int anss=n-1;
                cout<<anss<<endl;
            }
        }
        else{
            cout<<3<<endl;
        }
    }
    return 0;
}
